use std::convert::From;
use std::io;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum KvsError {
    #[error("can not found key: {key}")]
    NoKey { key: String },
    #[error("io error {0:?}")]
    IoErr(io::Error),
}

impl From<io::Error> for KvsError {
    fn from(error: io::Error) -> Self {
        KvsError::IoErr(error)
    }
}

pub type Result<T> = std::result::Result<T, KvsError>;
